<%@ Page Language="C#" MasterPageFile="~/Masterpages/Default.master" AutoEventWireup="true"
    Inherits="protected_ManageThemes" Title="Manage Templates and Themes" Codebehind="ManageThemes.aspx.cs" %>

<%@ Register Src="../Usercontrols/ChooseSite.ascx" TagName="ChooseSite" TagPrefix="uc1" %>
<%@ Register Src="../Usercontrols/Loading.ascx" TagName="Loading" TagPrefix="uc3" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <h1>
        Manage Template &amp; Themes</h1>
    <uc1:ChooseSite ID="ChooseSite1" runat="server"></uc1:ChooseSite>
    <hr />
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False"
                CellPadding="4" DataKeyNames="ID,RowState,RowStamp,Site" DataSourceID="odsMasterpage"
                ForeColor="#333333" GridLines="None" Width="95%" EmptyDataText="There are no templates in this site yet"
                OnSelectedIndexChanging="GridView1_SelectedIndexChanging">
                <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                <Columns>
                    <asp:BoundField DataField="ID" HeaderText="ID" ReadOnly="True" SortExpression="ID" />
                    <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                    <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
                    <asp:BoundField DataField="Path" HeaderText="Path" SortExpression="Path" />
                    <asp:CommandField SelectText="Themes" ShowDeleteButton="True" ShowEditButton="True"
                        ShowSelectButton="True" ButtonType="Link" />
                </Columns>
                <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                <EditRowStyle BackColor="#999999" />
                <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
            </asp:GridView>
            <br />
            <asp:LinkButton ID="LinkButtonInsert" runat="server" OnClick="LinkButtonInsert_Click"
                Visible="False">Insert Template</asp:LinkButton><br />

            <asp:LinkButton ID="LinkButtonInsertTemplate" runat="server">Insert</asp:LinkButton>
            <asp:Panel ID="PanelAddTemplate" runat="server" SkinID="PopupPanel1">
                <div class="PopupPanelInner" style="width: 300px;">
                    <asp:Panel runat="server" ID="PanelAddTemplateTitle" CssClass="PopupTitle">
                        Add Template</asp:Panel>

                    <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataSourceID="odsMasterpage"
                        OnItemCommand="DetailsView1_ItemCommand" DefaultMode="Insert" OnItemInserting="DetailsView1_ItemInserting"
                        BorderWidth="0px">
                        <Fields>
                            <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True"
                                SortExpression="ID" />
                            <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                            <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
                            <asp:BoundField DataField="Path" HeaderText="Path" SortExpression="Path" />
                            <asp:CommandField ShowInsertButton="True" />
                        </Fields>
                    </asp:DetailsView>
                </div>
            </asp:Panel>
            <ajax:ModalPopupExtender ID="ModalPopupExtender2" runat="server" TargetControlID="LinkButtonInsertTemplate"
                PopupControlID="PanelAddTemplate" PopupDragHandleControlID="PanelAddTemplateTitle"
                SkinID="Popup1">
            </ajax:ModalPopupExtender>
            
            <asp:ObjectDataSource ID="odsMasterpage" runat="server" DataObjectTypeName="Blazing.BusinessObjects.Cms.Masterpage"
                DeleteMethod="DeleteMasterpage" InsertMethod="NewMasterpage" OldValuesParameterFormatString="original_{0}"
                SelectMethod="GetMasterpages" TypeName="Blazing.WebFacade.ThemeController" UpdateMethod="UpdateMasterpage">
                <SelectParameters>
                    <asp:SessionParameter DefaultValue="-1" Name="siteId" SessionField="siteId" Type="Int32" />
                </SelectParameters>
            </asp:ObjectDataSource>
            <br />
            <hr />
            <asp:Panel ID="PanelAddTheme" runat="server" Visible="false">
                <h2>View Themes</h2>                        
                    <asp:UpdatePanel ID="UpdatePanel2" runat="server" ChildrenAsTriggers="true">
                        <ContentTemplate>
                            <asp:GridView ID="GridViewThemes" runat="server" AllowPaging="True" AutoGenerateColumns="False"
                                CellPadding="4" DataSourceID="odsThemes" ForeColor="#333333" GridLines="None"
                                Width="100%" DataKeyNames="ID,RowState,RowStamp" EmptyDataText="There are no themes for this template">
                                <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                <Columns>
                                    <asp:BoundField DataField="ID" HeaderText="ID" ReadOnly="True" SortExpression="ID" />
                                    <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                                    <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
                                    <asp:BoundField DataField="Path" HeaderText="Path" SortExpression="Path" />
                                    <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" ButtonType="Link" />
                                </Columns>
                                <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                                <EditRowStyle BackColor="#999999" />
                                <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                                <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                                <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                            </asp:GridView>
                            <br />
                            <asp:LinkButton ID="LinkButtonInsertThemes" runat="server" OnClick="LinkButtonInsertThemes_Click"
                                Visible="false">Insert</asp:LinkButton>
                            <br />
                        <asp:LinkButton ID="LinkButtonInsertATheme" runat="server">Insert</asp:LinkButton>
                     <asp:LinkButton ID="LinkButtonCloseWindow" runat="server" OnClick="LinkButtonCloseWindow_Click">Close Window</asp:LinkButton>
                    
                    <br />
                    
                    
                   <asp:Panel ID="PanelAddATheme" runat="server" SkinID="PopupPanel1">
                    <div class="PopupPanelInner" style="width: 300px;">
                    <asp:Panel runat="server" ID="PanelAddAThemeTitle" CssClass="PopupTitle">
                        Add Theme</asp:Panel>
                        
                        <div style="vertical-align: middle; text-align: center;">
                            <asp:DetailsView ID="DetailsViewTheme" runat="server" AutoGenerateRows="False" DataSourceID="odsThemes"
                                DefaultMode="Insert" OnItemCommand="DetailsViewTheme_ItemCommand" OnItemInserting="DetailsViewTheme_ItemInserting"
                                BorderWidth="0px">
                                <Fields>
                                    <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True"
                                        SortExpression="ID" />
                                    <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                                    <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
                                    <asp:BoundField DataField="Path" HeaderText="Path" SortExpression="Path" />
                                    <asp:CommandField ShowInsertButton="True" />
                                </Fields>
                            </asp:DetailsView>
                        </div>
                     </div>
            </asp:Panel>
            <ajax:ModalPopupExtender ID="ModalPopupExtender3" runat="server" TargetControlID="LinkButtonInsertATheme"
                PopupControlID="PanelAddATheme" PopupDragHandleControlID="PanelAddAThemeTitle"
                SkinID="Popup1">
            </ajax:ModalPopupExtender>
            
                    </ContentTemplate>
                    </asp:UpdatePanel>
                 </div>
            </asp:Panel>

            
                <asp:ObjectDataSource ID="odsThemes" runat="server" DataObjectTypeName="Blazing.BusinessObjects.Cms.Theme"
                    DeleteMethod="DeleteTheme" InsertMethod="NewTheme" OldValuesParameterFormatString="original_{0}"
                    SelectMethod="GetThemes" TypeName="Blazing.WebFacade.ThemeController" UpdateMethod="UpdateTheme">
                    <SelectParameters>
                        <asp:ControlParameter ControlID="GridView1" Name="ID" PropertyName="SelectedValue"
                            Type="Int32" />
                    </SelectParameters>
                </asp:ObjectDataSource>
        </ContentTemplate>
    </asp:UpdatePanel>
    <ajax:UpdateProgress runat="server" ID="update" DisplayAfter="50">
        <progresstemplate>
            <uc3:Loading ID="Loading1" runat="server" />
        </progresstemplate>
    </ajax:UpdateProgress>
    <br />
</asp:Content>
